import java.util.LinkedList;
import java.util.Queue;

/**
 * @author wangj881
 * @date 2024-11-26 9:56
 */
public class L225_2 {

    public static void main(String[] args) {
        MyStack myStack = new MyStack();
        myStack.push(1);
        myStack.push(2);
        myStack.push(3);
//        int top = myStack.top();
        int pop1 = myStack.pop();
        int pop2 = myStack.pop();
        int pop3 = myStack.pop();
        boolean empty = myStack.empty();
        System.out.println(1);

    }

    static class MyStack {

        Queue<Integer> up = new LinkedList<>();
        Queue<Integer> down = new LinkedList<>();

        void push(int x) {
            down.add(x);
            while (!up.isEmpty()) {
                down.add(up.poll());
            }
            Queue<Integer> tmp = this.down;
            down = up;
            up = tmp;
        }

        int pop() {
            return up.poll();
        }

        int top() {
            return up.peek();
        }

        boolean empty() {
            return up.isEmpty() && down.isEmpty();
        }


    }
}
